// 数字枚举
enum Color {
  RED,
  GREEN,
  YELLOW,
}

console.log(Color.RED); // 0
console.log(Color.GREEN); // 1
console.log(Color.YELLOW); // 2

console.log(Color[0]); // 'RED'
console.log(Color[1]); // 'GREEN'
console.log(Color[2]); // 'YELLOW'

// 数字枚举加默认赋值
enum HttpResult {
  GET = 3,
  POST = 2,
  PUT = 5,
  PATCH = 6,
}

// 字符串枚举
enum HttpMethod {
  GET = "1",
  POST = "2",
  PUT = "3",
  PATCH = "4",
}

// 异构枚举
enum HttpStatus {
  GET = 0,
  POST = "2",
  PUT = "3",
  PATCH = "4",
}

// 常量枚举
const enum Role {
  ADMIN,
  EDIT,
}

enum Status {
  "关闭",
  "开启",
}

console.log(Role.ADMIN); // 0
console.log(Role.EDIT); // 1

const code = 1;
Status[code];
